package com.lyy.king.tools.service.file.impl;

import com.lyy.king.common.utils.exception.BizException;
import com.lyy.king.tools.enums.ImportExcelOperatorTypeEnum;
import com.lyy.king.tools.model.request.ImportExcelRequest;
import com.lyy.king.tools.service.file.ExcelOperatorService;
import com.lyy.king.tools.service.file.handler.excel.ImportExcelOperatorEngineFactory;
import org.springframework.stereotype.Service;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: cdx
 * @Created: 2023/12/26 19:45
 */
@Service
public class ExcelOperatorServiceImpl implements ExcelOperatorService {
    @Override
    public boolean importExcel(ImportExcelRequest request) {
        ImportExcelOperatorTypeEnum operatorType = ImportExcelOperatorTypeEnum.getByCode(request.getOperatorType());
        BizException.check(operatorType != null ,"operatorType faield");
        return ImportExcelOperatorEngineFactory.get(operatorType).execute(request.getExcelFileDownUrl());
    }
}
